package com.timk.goserver.client.services;

import java.util.List;

import com.google.gwt.user.client.rpc.RemoteService;
import com.timk.goserver.client.model.ClientUserInfo;

/**
 * 
 * @author TKington
 *
 */
public interface UserService extends RemoteService {
	/** Success */
	int STATUS_SUCCESS = 0;
	/** Wrong password */
	int STATUS_INCORRECT_PASSWORD = 1;
	/** IOException, NoSuchAlgorithmException */
	int STATUS_INTERNAL_ERROR = 2;
	
	/**
	 * Returns the current user
	 * @return the user
	 * @throws NoSessionException if the session has expired
	 */
	ClientUserInfo getCurrentUser() throws NoSessionException;
	
	/**
	 * Returns a user by username
	 * @param username
	 * @return ClientUserInfo
	 * @throws NoSessionException if the session has expired
	 */
	ClientUserInfo getUser(String username) throws NoSessionException;
	
	/**
	 * Sets the current user's information
	 * @param info
	 * @throws NoSessionException if the session has expired
	 */
	void setUserInfo(ClientUserInfo info) throws NoSessionException;
	
	/**
	 * Changes the current user's password
	 * @param oldPassword
	 * @param newPassword
	 * @return integer error code
	 * @throws NoSessionException if the session has expired
	 */
	int changePassword(String oldPassword, String newPassword) throws NoSessionException;
	
	/**
	 * Returns a list of users matching the criteria
	 * @param firstResult index of first result
	 * @param maxResults number of results to return
	 * @param substring substring to match against usernames
	 * @return List&lt;ClientUserInfo&gt;
	 * @throws NoSessionException if the session has expired
	 * 
	 * @gwt.typeArgs <com.timk.goserver.client.model.ClientUserInfo>
	 */
	List getUsers(int firstResult, int maxResults,
			String substring) throws NoSessionException;
}
